﻿Imports System.Xml.Linq
Imports System.Xml

Public Class Main
    Public Shared Sub main()

        Dim critElements As XElement = <Criteria>
                                           <Criterion>

                                               <Name>BooleanCombo</Name>
                                               <ControlUIType>1</ControlUIType>
                                               <LabelText>Combo Box</LabelText>

                                           </Criterion>

                                           <Criterion>

                                               <Name>comborange</Name>
                                               <ControlUIType>1</ControlUIType>
                                               <LabelText>Combo Box From</LabelText>
                                               <LabelText2>Combo Box To</LabelText2>
                                               <IsRange>1</IsRange>
                                           </Criterion>

                                           <Criterion>

                                               <Name>TestControl2</Name>
                                               <ControlUIType>0</ControlUIType>
                                               <LabelText>very long label text, will it wrap?</LabelText>

                                           </Criterion>

                                           <Criterion>

                                               <Name>TestControl</Name>
                                               <ControlUIType>0</ControlUIType>
                                               <LabelText>Test</LabelText>
                                               <IsMandatory>1</IsMandatory>
                                               <DefaultValue>A</DefaultValue>
                                               <IsRange>1</IsRange>

                                               <LabelText2>To</LabelText2>
                                               <DefaultValue2>Ω</DefaultValue2>
                                               <IsMandatory2>1</IsMandatory2>
                                               <HelpText>This is sample help text!!</HelpText>

                                           </Criterion>

                                           <Criterion>

                                               <Name>TestControl2</Name>
                                               <ControlUIType>0</ControlUIType>
                                               <LabelText>From</LabelText>
                                               <DefaultValue>10</DefaultValue>
                                               <IsRange>1</IsRange>
                                               <IsMandatory>1</IsMandatory>
                                               <IsMandatory2>1</IsMandatory2>
                                               <LabelText2>To</LabelText2>
                                               <DefaultValue2>100</DefaultValue2>
                                               <HelpText>Enter a number from 10 to 100, included.  Do not enter a decimal number</HelpText>

                                           </Criterion>

                                           <Criterion>
                                               <!-- date control -->
                                               <Name>TestControl3</Name>
                                               <ControlUIType>2</ControlUIType>
                                               <LabelText>Date From</LabelText>

                                               <DefaultValue>1/1/1900</DefaultValue>
                                               <DefaultValue2>31/12/3000</DefaultValue2>

                                               <IsRange>1</IsRange>

                                               <LabelText2>To</LabelText2>
                                               <DefaultValue2></DefaultValue2>

                                           </Criterion>

                                           <Criterion>

                                               <Name>TestControl4</Name>
                                               <ControlUIType>3</ControlUIType>
                                               <LabelText>Integer From</LabelText>
                                               <DefaultValue></DefaultValue>
                                               <IsRange>1</IsRange>

                                               <LabelText2>To</LabelText2>
                                               <DefaultValue2></DefaultValue2>

                                           </Criterion>

                                       </Criteria>

        Dim xmlDoc As XmlDocument
        Using xmlReader As XmlReader = critElements.CreateReader()

            xmlDoc = New XmlDocument()
            xmlDoc.Load(xmlReader)


            Dim ldr As XMLCriteriaProvider = New XMLCriteriaProvider
            Dim r As New ReportMatadata
            CriterionMetadata.defaultCriterionUIHandler = New CriterionHandler()

            r.DisplayName = "Test Report"
            r.Criteria = ldr.loadCriteriaControls(xmlDoc.DocumentElement)
            Dim f As New frmCriteria
            f.setReportMetadata(r)
            f.ShowDialog()

        End Using

    End Sub
End Class
